package ${targetPackage};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;

import ${modelClass};
import ${modelClass}Example;
import ${serviceClass};
import java.util.List;

/**
* 由代码生成器生成
*/
@RestController
@RequestMapping("/${requestMapping}")
public class ${className}Controller{

    @Autowired
    private ${className}Service ${serviceName}Service;

    /**
     * 新增
     *
     */
    @RequestMapping("/add")
    public int add(${className} ${serviceName}) {
        return ${serviceName}Service.insertSelective(${serviceName});
    }

    /**
     * 修改
     *
     */
    @RequestMapping("/update")
    public int update(${className} ${serviceName}) {
        return ${serviceName}Service.updateByPrimaryKeySelective(${serviceName});
    }

    /**
     * 删除
     *
     */
    @RequestMapping("/delete")
    public int delete(${pkType}) {
        return ${serviceName}Service.deleteByPrimaryKey(${pkName});
    }

    /**
     * 查询所有
     *
     */
    @RequestMapping("/list")
    public List<${className}> list(){
         return ${serviceName}Service.selectByExample(null);
    }

     /**
     * 分页查询
     *
     */
    @RequestMapping("/pageList")
    public List<${className}> pageList(@RequestParam(defaultValue = "1")int pageNum, @RequestParam(defaultValue = "10")int pageSize){
        ${className}Example example = new ${className}Example();
        //分页查询
        example.setLimitStart((pageNum-1) * pageSize);//从第几条开始取（索引从0开始）
        example.setLimitEnd(pageSize);//取多少条
        return ${serviceName}Service.selectByExample(example);
    }
}